package com.wswy.wyjk.ui.dialog;

import android.app.Dialog;
import android.content.Context;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;

import com.wswy.wyjk.R;
import com.wswy.wyjk.ui.widget.CircleProgressView;


public class CircleProgressDialog extends Dialog {
    public CircleProgressDialog(Context context) {
        super(context);
    }

    public CircleProgressDialog(Context context, int theme) {
        super(context, theme);
    }

    public static class Builder {
        private Context context;
        private View contentView;
        private CircleProgressView circleProgressView;

        public Builder(Context context) {
            this.context = context;
        }


        public Builder setContentView(View v) {
            this.contentView = v;
            return this;
        }

        public CircleProgressDialog create() {
            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            // instantiate the dialog with the custom Theme
            final CircleProgressDialog dialog = new CircleProgressDialog(context, R.style.AlertDialogStyle);
            View layout = inflater.inflate(R.layout.dialog_circle_progress_layout, null);
            dialog.addContentView(layout, new LayoutParams(
                    LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

            circleProgressView = layout.findViewById(R.id.circle_progress_view);

            dialog.setContentView(layout);
            return dialog;
        }

        public void loadProgress(float progress) {
            if (circleProgressView != null) {
                circleProgressView.setProgress(progress);
            }
        }
    }
}
